{extend name="base"}
{block name="title"}游戏道具查询{/block}
{block name="head"}
{/block}
{block name="body"}
<body class="mainbody">
<form>
    <!--导航栏-->
    <div class="location">
        <a href="javascript:history.back(-1);" class="back"><i class="iconfont icon-up"></i><span>返回上一页</span></a>
        <a href="{:url('index/home')}" class="home"><i class="iconfont icon-home"></i><span>首页</span></a>
        <i class="arrow iconfont icon-arrow-right"></i>
        <span>游戏道具列表</span>
    </div>
    <!--/导航栏-->

    <div id="floatHead" class="toolbar-wrap">
        <div class="toolbar">
            <div class="box-wrap">
                <a class="menu-btn"><i class="iconfont icon-more"></i></a>
                <div class="l-list">
                    <div class="menu-list">
                        <div class="rule-single-select">
                            <select name="channel" style="display:none">
                                {volist name="CHANNELS" id='val'}
                                <option value="{$key}"{eq name="channel" value="$key"} selected{/eq}>[{$key}]{$val.Name}</option>
                                {/volist}
                            </select>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="table-container">
        <table class="ltable border-table">
            <thead>
            <tr>
                <th>#</th>
                <th>渠道</th>
                <th>道具索引</th>
                <th>道具名称</th>
                <th>道具类型</th>
                <th>消耗的游戏豆数</th>
                <th>消耗的金币数</th>
                <th>消耗的房卡数</th>
                <th>写入记录描述</th>
                <th>是否启用</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            {empty name="list"}
            <tr><td colspan="10">Oh~暂无数据!</td></tr>
            {else/}
            {volist name="list" id="v"}
            <tr data-id="{$v.ID}" data-name="{$v.PropsName}">
                <td>{$v.ID}</td>
                <td>[{$v.Channel}]{$CHANNELS[$v.Channel]['Name'] ?? ''}</td>
                <td>{$v.PropsIndex}</td>
                <td>{$v.PropsName}</td>
                <td>[{$v.PropsType}]{$AWTYPES[$v.PropsType] ?? ''}</td>
                <td>{$v.Cash}</td>
                <td>{$v.Gold}</td>
                <td>{$v.Card}</td>
                <td>{$v.GameProsName}</td>
                {eq name="v.Status" value="1"}
                <td><a href="javascript:;" style="color: green;" class="status" status_id="{$v.ID}" val="{$v.Status}">启用</a></td>
                {else/}
                <td><a href="javascript:;" style="color:red;" class="status" status_id="{$v.ID}" val="{$v.Status}">未启用</a></td>
                {/eq}
                <td><input type="button" value="修改" /></td>
            </tr>
            {/volist}
            {/empty}
            </tbody>
        </table>
    </div>

    <div class="page-footer"><div class="btn-wrap">{$list->render()}</div></div>

</form>
<script>
    $(function () {
        $(".status").click(function () {　　　//修改道具状态
            var id = $(this).attr('status_id');
            var status = $(this).attr('val');
            dialog({
                title: '提示',
                content: '确认修改道具[' + id + ']状态',
                okValue: '确定',
                cancelValue: '取消',
                cancel: function () {},
                ok: function () {
                    $.post("{:url('updateprops')}", {ID:id,Status:status}, function (resp, text, xhr) {
                        console.log(resp);

                        if (resp.errno == 0) {
                            alert(resp.error)
                            location.reload();
                        }
                    });
                    return false;
                }
            }).showModal();
        });
        // 修改道具
        $('input[type=button]').click(function () {
            var tr = $(this).parents('tr');
            var id = tr.data('id');
            var name = tr.data('name');
            var url = "{:url('detail')}?id=" + id;
            dialog({
                title: '修改道具[' + id + ']'+name,
                url: url,
                width: 500,
                height: 420,
                okValue: '确定',
                cancelValue: '取消',
                cancel: function () {},
                ok: function () {
                    var f = $('iframe', this.node);
                    var v = $('form', f.contents()).serialize();
                    console.log(v);
                    $.post(url, v, function (resp, text, xhr) {
                        console.log(resp);
                        alert(resp.error);
                        if (resp.errno == 0 || resp.errno == 110) {
                            location.reload();
                        }
                    });
                    return false;
                }
            }).showModal();
        });

    });
</script>
</body>
{/block}